#include <string>
#include <iostream>
#include <sstream>
#include <memory>

#include <windows.h>

//#include "osg/error.hpp"
#include "osg/form.hpp"
#include "osg/button.hpp"
#include "osg/edit.hpp"

//using namespace osg;
using namespace std;

class control
{
public:
	virtual void location(int x, int y) {};
	virtual void size(int x, int y) {};
	virtual void text(const wstring& value) {};

	virtual string name() { return "control"; };
};
class form : public control
{
public:
	void add(shared_ptr<control> ctl) {
		auto name = ctl->name();
	};
	void show() {};
	virtual string name() { return "form"; };
};
class edit : public control
{
public:
	virtual string name() { return "edit"; };
};
class button : public control
{
public:
	void click();
	virtual string name() { return "button"; };
};


int main()
{
	try
	{
		// form
		shared_ptr<form> frm(new form());
		frm->size(400, 300);
		frm->text(L"Hello World");

		// edit
		shared_ptr<edit> edt(new edit());
		edt->location(50, 50);
		edt->size(120, 20);
		edt->text(L"my edit control");
		frm->add(edt);

		// button
		shared_ptr<button> btn(new button());
		btn->location(300, 260);
		btn->size(80, 20);
		btn->text(L"foo");
		frm->add(btn);

		//// event
		//btn.click += [&]()
		//{
		//	// TODO
		//};
		//frm.closing += [&]()
		//{
		//	// TODO
		//	msgbox::show(L"on closing", frm);
		//	return true;
		//};

		// show form
		frm->show();

		// throw an exception on purpose
		//throw_error(application_error, L"my test app error");
	}
	catch(const exception& e)
	{
		//msgbox::show(e.trace());
		return -1;
	}

	return 0;
}

int WINAPI wWinMain(
    _In_ HINSTANCE hInstance,
    _In_opt_ HINSTANCE hPrevInstance,
    _In_ LPWSTR lpCmdLine,
    _In_ int nShowCmd
    )
{
	return main();
}